package com.esms.controller;

import com.esms.service.ILogService;
import com.esms.utils.Message;
import com.esms.vo.LogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/log")
public class LogController {

    @Autowired
    ILogService logService;

    @GetMapping("pageLogInfo")
    @ResponseBody
    public Object pageLogInfo(@RequestParam(value = "pageSize") Integer pageSize,
                              @RequestParam(value = "pageCount") Integer count,
                              @RequestParam(value = "account", required = false) String account,
                              @RequestParam(value = "preDateTime", required = false) String preTime,
                              @RequestParam(value = "aftDateTime", required = false) String aftTime){
        try {
//            Timestamp date = new Timestamp(new Date().getTime());
//            return logService.PageLogInfo(pageSize, count, account, time==null?null:Timestamp.valueOf(time));
            return logService.PageLogInfo(pageSize, count, account, preTime,aftTime);
        }catch (Exception e){
            return Message.fail();
        }
    }

}
